//
//  foundQuestModel.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/31.
//

#import "foundQuestModel.h"

@implementation foundQuestModel

+ (NSDictionary *)modelCustomPropertyMapper {
    return @{
        @"tissueName":@[@"pondTissueName",@"tissueName"],
        @"tissueId":@[@"pondTissueId",@"tissueId"],
    };
}
-(NSMutableArray <TemplateFoundDetailsTaskTypeModelListModel*>*)taskTypeModelList{
    if(!_taskTypeModelList){
        _taskTypeModelList = [NSMutableArray array];
    }
    return _taskTypeModelList;
}

- (NSMutableArray<pondModelListModel *> *)pondModelListModel{
    if(!_pondModelListModel){
        _pondModelListModel = [NSMutableArray array];
    }
    return _pondModelListModel;
}

- (CGFloat)HeaderTopViewH{
    if(self.taskTypeModelList.count > 0){
        return kwt(190) + self.HeaderTopPondViewH;
    } else {
        return kwt(190) + self.HeaderTopPondViewH + kwt(63);
    }
}
- (CGFloat)HeaderTopPondViewH{
    return self.pondModelListModel.count * kwt(28);
}
-(NSMutableArray<pondModelListModel *> *)CopyPondModelListModel{
    NSMutableArray * CopyPondModelListModel = [NSMutableArray array];
    for (pondModelListModel * model in self.pondModelListModel) {
        pondModelListModel * newModel = [pondModelListModel yy_modelWithJSON:[model yy_modelToJSONObject]];
        [CopyPondModelListModel addObject:newModel];
    }
    
    return CopyPondModelListModel;
}
- (NSString *)TjAPiHUDString {
    if(self.tissueId.length < 1){
        return @"请选择池塘编组";
    }
    if(self.templateId.length < 1){
        return @"请选择工作模版";
    }
    if(self.pondModelListModel.count < 1){
        return @"请选择池塘名称";
    }
    if(self.taskTypeModelList.count < 1){
        return @"请选择任务";
    }
    
    for (TemplateFoundDetailsTaskTypeModelListModel * model in self.taskTypeModelList) {
        if([model TjRWAPiHUDString].length > 0){
            return [model TjRWAPiHUDString];
        }
    }
    return @"";
}
- (NSMutableDictionary *)TjDict {
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    [dict setObject:self.templateId forKey:@"templateId"];
    [dict setObject:self.templateName forKey:@"templateName"];
    [dict setObject:self.tissueId forKey:@"tissueId"];
    [dict setObject:self.TJtissueName forKey:@"tissueName"];

    NSMutableArray * taskTypeModelList = [NSMutableArray array];
    for (TemplateFoundDetailsTaskTypeModelListModel * model in self.taskTypeModelList) {
        [taskTypeModelList addObject: [model TjRWDict]];
    }
    [dict setObject:taskTypeModelList forKey:@"taskTypeModelList"];

    return dict;
}
@end
@implementation pondModelListModel
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"ID":@[@"id"],
    };
}

+ (NSDictionary *)modelContainerPropertyGenericClass {
    return @{
        @"taskItemModelList":[TemplateFoundDetailsTaskItemModelListModel class],
    };
}
//- (NSMutableArray<TemplateFoundDetailsTaskItemModelListModel *> *)DZXXtaskItemModelList{
//    if(!_DZXXtaskItemModelList){
//        _DZXXtaskItemModelList = [NSMutableArray array];
//        for (TemplateFoundDetailsTaskItemModelListModel * model in self.taskItemModelList) {///所有任务
//            if(model.pattern == 1){///多选
//                BOOL ishave = NO;
//                for (TemplateFoundDetailsItemModelListModel * listModel in model.itemModelList) {///多选任务项
//                    if(listModel.itemList > 0){///带子选项
//                        ishave = YES;
//                    }
//                }
//                if(ishave){
//                    [_DZXXtaskItemModelList addObject:model];
//                }
//            }
//        }
//    }
//    return _DZXXtaskItemModelList;
//}
- (CGFloat)RWcellH{///任务高度
    CGFloat H = kwt(40);
    if(self.isSQ){
        return H;
    }
    for (TemplateFoundDetailsTaskItemModelListModel * itemModel in self.taskItemModelList) {
        H += itemModel.RWDXXZViewH;
    }
    return H;
}
- (CGFloat)YTDKcellH{//打卡的高度
    CGFloat H = kwt(55);
    if(self.isSQ){
        return kwt(63);
    }
    for (TemplateFoundDetailsTaskItemModelListModel * itemModel in self.taskItemModelList) {
        
        H += itemModel.DKDXXZViewH;
    }
    return H;
}
- (CGFloat)RWBGcellH{
    return kwt(45);
}
- (NSMutableDictionary *)TjRWDict{
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    [dict setObject:self.name forKey:@"name"];
    [dict setObject:self.ID forKey:@"id"];
    [dict setObject:self.batchFlag forKey:@"batchFlag"];

    
    NSMutableArray * taskItemModelList = [NSMutableArray array];
    for (TemplateFoundDetailsTaskItemModelListModel * model in self.taskItemModelList) {
        [taskItemModelList addObject:[model TjDictWithNew:YES]];
    }
    [dict setObject:taskItemModelList forKey:@"taskItemModelList"];
    
    return dict;
}
- (NSMutableDictionary *)TjDKDict{
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    [dict setObject:self.name forKey:@"name"];
    [dict setObject:self.ID forKey:@"id"];
    [dict setObject:self.batchFlag forKey:@"batchFlag"];
    
    
    NSMutableArray * taskItemModelList = [NSMutableArray array];
    for (TemplateFoundDetailsTaskItemModelListModel * model in self.taskItemModelList) {
        [taskItemModelList addObject:[model TjDictWithNew:NO]];///打卡用NO
    }
    [dict setObject:taskItemModelList forKey:@"taskItemModelList"];
    
    return dict;
}

@end
